package org.biubiu0002.baiblog.common.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;

/**
 * @Author: biubiu0002
 * @Date: 2022/7/30 20:10
 **/
@Data
public class PageQuery<T> extends Page<T> {
    int offset;
    public PageQuery(){}
    public PageQuery(Map<String,Object> params){
        super(Integer.parseInt((String) params.get("page")), StringUtils.isBlank((String)params.get("limit"))?15L:
                Integer.parseInt((String)params.get("limit")));
        this.offset = (int) ((current-1)*size);
    }

    public PageQuery(int page,int limit){
        this(page,15,limit);
    }

    public PageQuery(int page,int pageSize,int limit){
        super(page,pageSize, pageSize);
        this.offset = (int) ((current-1)*size);
    }
}
